package com.app.view.component.dialogs 
{
	import com.app.model.data.UserData;
	import flash.geom.Point;
	import flash.display.SimpleButton;
	import flash.events.MouseEvent;
	import flash.events.Event;
	
	import com.peachcastle.core.Dialog;
	import org.component.Button;
	
	import com.app.view.manager.DialogManagerMediator;
	import com.app.view.component.dialogs.createRoom.Form;
	
	/**
	 * ...
	 * @author kevin
	 */
	public class CreateRoom extends Dialog 
	{
		private var _dialogManagerMediator:DialogManagerMediator = null;
		
		private var _btn_cancel:SimpleButton = null;
		private var _btn_submit:Button = null;
		
		private var _form:Form = null;
		
		public function CreateRoom(dialogUrlFunc:Function, dialogManagerMediator:DialogManagerMediator) 
		{
			_dialogManagerMediator = dialogManagerMediator;
			super("CreateRoom", true, dialogUrlFunc, 
					_dialogManagerMediator.stageSize["width"], _dialogManagerMediator.stageSize["height"]);
		}
		
		override protected function initialization():void 
		{
			super.initialization();

			//move(25, 195);
			setCenter();
			
			_btn_cancel = assest["btn_cancel"];
			_btn_submit = new Button(assest["btn_submit"]);
		}
		
		override protected function configureEventListeners():void 
		{
			super.configureEventListeners();
			_btn_cancel.addEventListener(MouseEvent.CLICK, onClose);
			_btn_submit.addEventListener(MouseEvent.CLICK, onSubmit);
		}
		
		override protected function showAction():void 
		{
			super.showAction();
			
			_form = new Form(assest["mc_form"], data as UserData);
		}
		
		private function onSubmit(e:MouseEvent):void
		{
			super.hide();
			_dialogManagerMediator.sendNotification(DialogManagerMediator.CREATEROOM_SEND_INFO, [_form.name, _form.minPour]);
		}
		private function onClose(e:MouseEvent):void 
		{
			super.hide();
		}
	}

}